package com.kldy8.kldyw.filmfactory.bean;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 城市筛选
 * Created by Administrator on 2016/9/5.
 */
public class City
{
    public int id;
    public String name;
    public String pid;
    public List<Son> sons = new ArrayList<Son>();

    public void resolution(JSONObject jsonObject)
    {
        if (jsonObject == null)
        {
            return ;
        }
        this.id = jsonObject.optInt("id");
        this.name = jsonObject.optString("name");
        this.pid = jsonObject.optString("pid");

        JSONArray array =  jsonObject.optJSONArray("son");
        if (array!=null) {
            for (int i = 0; i < array.length(); i++) {
                JSONObject jsonSon = array.optJSONObject(i);
                Son son = new Son();
                son.id = jsonSon.optInt("id");
                son.name = jsonSon.optString("name");
                son.pid = jsonSon.optString("pid");
                sons.add(son);
            }
        }
    }

    public class Son
    {
        public int id;
        public String name;
        public String pid;
    }
}
